perm filename TRIG.PAS[11,HE] blob sn#620499 filedate 1981-10-23 generic text, type T, neo UTF8
{$E+  Trig functions module}

{ External routines are:
function sind(d: real): real;
function cosd(d: real): real;
function tand(d: real): real;
function asin(x: real): real;
function acos(x: real): real;
function arctan2(y,x: real): real;
}


{These functions are mainly used by the arm solution routines}
{These functions are needed by my routines but are not pre-defined in Pascal.}


const
    rad = 0.0174532925;		{Number of radians in a degree }


function sind(d: real): real; begin sind := sin(rad*d) end;
function cosd(d: real): real; begin cosd := cos(rad*d) end;
function tand(d: real): real; begin tand := sin(rad*d)/cos(rad*d) end;
function asin(x: real): real; begin asin := arctan(x/sqrt(1.0-x*x))/rad end;
function acos(x: real): real; begin acos := arctan(sqrt(1.0-x*x)/x)/rad end;

function arctan2(y,x: real): real; 	{4-quadrant arctan(y/x) }
var ans: real;
begin 
if x=0.0 then
  begin
  if y = 0.0 then ans:=0.0	{This is actually indeterminate, but ...}
  else if y > 0.0 then ans:=90.0
  else ans:=-90.0;
  end
else
  begin 
  ans:=arctan(y/x)/rad;
  if x < 0 then 
    if y < 0 then ans:=ans-180
    else ans:=ans+180;
  end;
arctan2:=ans;
end;